package handler

import (
	"api/basic/global"
	__ "api/basic/proto"
	"api/internal/params"
	"github.com/gin-gonic/gin"
	"net/http"
)

func SendSms(c *gin.Context) {
	var req *params.MobileReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	code, err := global.SendSmsClient.SendSms(c, &__.SendSmsReq{
		Mobile: req.Mobile,
	})
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{
			"error": err.Error(),
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "发送成功",
		"data": code,
	})

}
